package org.gcu.filestorage.configuration;

import io.minio.MinioClient;
import org.gcu.filestorage.pojo.MinioProperties;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class MinioConfiguration {

    private final MinioProperties minioProperties;

    @Autowired
    public MinioConfiguration(MinioProperties minioProperties) {
        this.minioProperties = minioProperties;
    }

    @Bean
    public MinioClient minioClient() {
        return MinioClient.builder()
                .endpoint(this.minioProperties.getEndpoint())
                .credentials(this.minioProperties.getAccessKey(), this.minioProperties.getSecretKey())
                .build();
    }
}
